package com.hxl.alert.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class AlertTimeUtils {

    private static final ThreadLocal<SimpleDateFormat> threadLocalDateFormat =
            ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));

    public static SimpleDateFormat getSdf() {
        return threadLocalDateFormat.get();
    }

    public static long toTimestamp(String occurTime) throws ParseException {
        return getSdf().parse(occurTime).getTime();
    }
}